import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  // state: 存放要全局共享的数据
  state: {
    //  islogin: sessionStorage.getItem("islogin"),
    // 使用持久化的数据作为初始值
    uname: JSON.parse(sessionStorage.getItem("users")),
    avatar: sessionStorage.getItem('avatar')
  },
  mutations: {
    loginOk(state, obj) {
      // state.uname = obj.nick_name;
      state.uname = obj;
      // state.avatar = obj.avatar;
      // state.islogin = true;
    },
    updateAvatar(state,str){
      state.avatar=str;
    }
  },
  actions: {},
  modules: {},
});
